package com.xd.springboot.controller;

import com.xd.springboot.jms.MsgProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.jms.Destination;
import javax.jms.Topic;

@RestController
@RequestMapping("/mq")
public class MQController {

    private  static  final Logger log= LoggerFactory.getLogger(MQController.class);
    @Resource
    private MsgProducer producer;
    @Resource
    private Destination queue;
    @Resource
    private Destination topic;
    @GetMapping("/send/queue")
    public  String sendQueueMsg()
    {
        log.info("============发送1条消息进入队列============");
        producer.sendMessage(queue,"Queue:hello,test mq send");
        return "success";
    }
    @GetMapping("/send/topic")
    public String sendTopicMessage()
    {
        log.info("============发送1条topic消息============");
        producer.sendMessage(topic,"Topic:hello,test topic msg");
        return "success";
    }
}
